package com.fulihui.common.util;

import com.fulihui.common.error.InvokeServiceException;
import com.fulihui.common.result.rpc.BaseResult;

/**
 * rpc服务返回校验工具
 * @author: Levon
 * @version: v 0.1 2018-06-14 14:54
 */
public class RpcResultCheckUtil {

    public static void checkResult(BaseResult result) {
        if (result.getErrcode() != BaseResult.SUCCESS) {
            throw new InvokeServiceException(result.getErrcode(), result.getErrmsg());
        }
    }

    public static boolean isSuccess(BaseResult result) {
        return result.getErrcode() == BaseResult.SUCCESS;
    }

}
